<?php

namespace app\common\model\search;

trait DiseaseSearch
{
    //疾病名称
    public function searchNameAttr($query, $value, $data)
    {
        // 定义需要转义的特殊字符
        $specialChars = ['(', ')'];

        // 使用 str_replace 进行转义
        foreach ($specialChars as $char) {
            $value = str_replace($char, '\\' . $char, $value);
        }

        return $query->where("type", 1)->whereLike('name', trim($value));
    }

    //疾病编码
    public function searchIllnessnoAttr($query, $value, $data)
    {
        return $query->whereLike('illnessno', trim($value));
    }
}